<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>HW1 - Calculator</title>
		<script type="text/javascript" src="WEB-INF/lib/javascript/jquery-1.6.3.min.js"></script>
		<script type="text/javascript">
		$(document).ready(function() {
			$(".opBtn").each(function(domEle){
				$(this).click(function(){
					var x = parseInt($("input=[name=xField]").val());
					var y = parseInt($("input[name=yField]").val());
					var opt = $(this).html();
					//console.log(opt);
					var rel;
					switch(opt)
					{
					case '+':
						rel = x + y;
						break;
					case '-':
						rel = x - y;
						break;
					case '*':
						rel = x * y;
						break;
					case '/':
						rel = x / y;
						break;
					}
					$("#rel").append("<div>" + x + " "+ opt +" " + y + " = " + rel +"</div>");
				});
			});
		});
		</script>
	</head>
	
	<body>
		<div>
			<input type="text" name="xField" value="" />
			<input type="text" name="yField" value="" />
			<button class="opBtn">+</button>
			<button class="opBtn">-</button>
			<button class="opBtn">*</button>
			<button class="opBtn">/</button>
			<br>
			<div id="rel"></div>
		</div>
	</body>
</html>
